package com.airlines.runlimit.service.impl;

import java.util.List;
import java.util.Map;

import javax.annotation.Resource;
import org.springframework.stereotype.Service;
import com.airlines.common.Page;
import com.airlines.crewassignment.domain.Crew;
import com.airlines.runlimit.dao.SchonflictMapper;
import com.airlines.runlimit.domain.Schconflict;
import com.airlines.runlimit.service.SchconflictService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
/**
 * 
 * @Description:人员冲突service
 * @author ouwen
 * @Date 2018年9月18日
 */
@Service("schconflictService")
public class SchconflictServiceImpl implements SchconflictService {

	/**
	 * 人员冲突dao接口
	 */
	@Resource
	private SchonflictMapper schonflictMapper;
	
	/**
	 * 条件查询分页数据
	 * @param schconflict
	 * @param page
	 * @return
	 */
	@Override
	public Page list(Schconflict schconflict, Page page) {
		PageHelper.startPage(page.getPageNumber(), page.getPageSize());
		List<Schconflict> list = schonflictMapper.listByQuery(schconflict);
		PageInfo<Schconflict> pageInfo = new PageInfo<Schconflict>(list);
		System.out.println(list);
		page.setTotal(String.valueOf(pageInfo.getTotal()));
		page.setRows(pageInfo.getList()); 
		return page;
	}
	
	/**
	 * 动态获取人员信息
	 * @param parameters
	 * @return
	 */
	@Override
	public List<Crew> listStaffPcode(Map<String, String> parameters) {
		return schonflictMapper.listStaffPcode(parameters);
	}

	/**
	 * 数据库新增一个数据
	 * @param schconflict
	 * @return
	 */
	@Override
	public int insertOne(Schconflict schconflict) {
		return schonflictMapper.insertOne(schconflict);
	}

	/**
	 * 根据id获取一个数据
	 * @param id
	 * @return
	 */
	@Override
	public Schconflict getConflictById(String id) {
		return schonflictMapper.getConflictById(id);
	}

	/**
	 * 执行更新操作
	 * @param schconflict
	 * @return
	 */
	@Override
	public int updateOne(Schconflict schconflict) {
		return schonflictMapper.updateOne(schconflict);
	}

	/**
	 * 根据id删除一个数据
	 * @param id
	 * @return
	 */
	@Override
	public int deleteOne(String id) {
		return schonflictMapper.deleteOne(id);
	}

}
